package com.bxl.netty.rpc.client.common.rule;


import com.bxl.netty.rpc.client.common.client.ClientInfo;

import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * <>
 *
 * @author baixl
 * @date 2021/2/24
 */
public class PollLoadBalance implements LoadBalance {
    
    private AtomicInteger index = new AtomicInteger(0);
    public ClientInfo choose(List<ClientInfo> clientInfos) {
        if(clientInfos == null && clientInfos.isEmpty()){
            return null;
        }
        return clientInfos.get(index.getAndIncrement() % clientInfos.size());
    }
}
